package main

import "time"

const TTL = 60 * 60

type ServerConfig struct {
	Host         string `mapstructure:"host"`
	Mode         string `mapstructure:"mode"`
	ServerName   string `mapstructure:"servername"`
	Port         int    `mapstructure:"port"`
	AuthFilePath string `mapstructure:"authpath"`
}

//secret,ip,tls_required,topic,channel,subscribe,publish
type Authorization struct {
	IP          string   `json:"ip"`
	TlsRequired bool     `json:"tls_required"`
	Topic       string   `json:"topic"`
	Channels    []string `json:"channels"`
	Subscribe   string   `json:"subscribe"`
	Publish     string   `json:"publish"`
}

type AuthReq struct {
	RemoteIP   string `form:"remote_ip"`
	TLS        bool   `form:"tls"`
	Secret     string `form:"secret"`
	CommonName string `form:"common_name"`
}

type ResAuthorization struct {
	Topic       string   `json:"topic"`
	Channels    []string `json:"channels"`
	Permissions []string `json:"permissions"`
}

type AuthResp struct {
	TTL            int                `json:"ttl"`
	Authorizations []ResAuthorization `json:"authorizations"`
	Identity       string             `json:"identity"`
	IdentityURL    string             `json:"identity_url"`
	Expires        time.Time
}
